home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra_2 / testvb.zip / MAIN.CPP < prev    next >
C/C++ Source or Header  |  1995-11-02  |  2KB  |  82 lines

  1. //-------------------------------------------------------------------
  2.  
  3. // MAIN.CPP
  4.  
  5. // Copyright (c) 1995 by Golden Gate Software
  6.  
  7. // Written by:
  8. //    Richard D. Kligman
  9. //    3825 Baker Street
  10. //    San Diego, CA  92117-5706
  11. //    (619) 483-8496
  12. //    FAX: (619) 483-4651
  13. //    CompuServe: 75300,2530
  14.  
  15. //-------------------------------------------------------------------
  16.  
  17. #include <windows.h>
  18. #include <string.h>
  19. #include "main.h"
  20.  
  21. extern "C" int FAR PASCAL LibMain(HANDLE hInstance, WORD wDataSeg, WORD wHeapSize, LPSTR lpsxCmdLine);
  22.  
  23. int FAR PASCAL LibMain(HANDLE hInstance, WORD wDataSeg, WORD wHeapSize, LPSTR lpsxCmdLine)
  24. {
  25.   if (wHeapSize > 0)
  26.     UnlockData(0);
  27.  
  28.   return 1;
  29. }
  30.  
  31.  
  32. //-------------------------------------------------------------------
  33. // Constructor for MyClass
  34. //-------------------------------------------------------------------
  35. MyClass::MyClass()
  36. {
  37. }
  38.  
  39.  
  40. //-------------------------------------------------------------------
  41. // Destructor for MyClass
  42. //-------------------------------------------------------------------
  43. MyClass::~MyClass()
  44. {
  45. }
  46.  
  47. //-------------------------------------------------------------------
  48. // Take two strings and make a third concatonated string
  49. //-------------------------------------------------------------------
  50. void MyClass::AddStrings(const char* strA, const char* strB, char* newStr, int len)
  51. {
  52.    // Keep track of the total length of the string. We don't want to exceed
  53.    // the space allocated.
  54.    int   totalLen;
  55.  
  56.    // Copy the first string up to the length of the string allocated
  57.    strncpy(newStr, strA, len);
  58.    newStr[len-1] = NULL;
  59.  
  60.    // Find out how big newStr is now
  61.    totalLen = strlen(newStr);
  62.  
  63.    // Add the second string to the first up to the allocated space
  64.    strncat(newStr, strB, (len - totalLen));
  65.    newStr[len-1] = NULL;
  66. }
  67.  
  68.  
  69.  
  70. //-------------------------------------------------------------------
  71. // C interface function
  72. //-------------------------------------------------------------------
  73. void _export PASCAL AddStrings(const char* strA, const char* strB, char* newStr, int len)
  74. {
  75.    // Instantiate MyClass
  76.    MyClass  classA;
  77.  
  78.    // Call the concatonation function in MyClass
  79.    classA.AddStrings(strA, strB, newStr, len);
  80. }
  81.  
  82.